package com.wskj.common.utils.tool;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public class Condition {

    public Condition() {
    }

    public static <T> IPage<T> getPage(Query query) {
        Page<T> page = new Page((long)Func.toInt(query.getPageNum(), 1), (long)Func.toInt(query.getPageSize(), 10));
        String[] ascArr = Func.toStrArray(query.getAscs());
        String[] descArr = ascArr;
        int var4 = ascArr.length;

        int var5;
        for(var5 = 0; var5 < var4; ++var5) {
            String asc = descArr[var5];
            page.addOrder(new OrderItem[]{OrderItem.asc(StringUtil.cleanIdentifier(asc))});
        }

        descArr = Func.toStrArray(query.getDescs());
        String[] var8 = descArr;
        var5 = descArr.length;

        for(int var9 = 0; var9 < var5; ++var9) {
            String desc = var8[var9];
            page.addOrder(new OrderItem[]{OrderItem.desc(StringUtil.cleanIdentifier(desc))});
        }

        return page;
    }

    public static <T> QueryWrapper<T> getQueryWrapper(T entity) {
        return new QueryWrapper(entity);
    }
}
